from tkinter import *

root = Tk()

root.title("Frame")
root.geometry("300x300")

# 上面部分
Label(root, bg="purple", text="top").pack()
frame = Frame(root)
frame.pack(padx =10, pady = 10)
Label(root, bg="purple", text="top").pack()     # 写在此处 会出现在文档尾部 因为下面两个元素是含在frame元素内的

# 左边部分
frame_l = Frame(frame)
frame_l.pack(side = 'left')
Label(frame_l, text = "left", bg = "green").pack()

# 右边部分
frame_r = Frame(frame)
frame_r.pack(side = "right")
Label(frame_r, text = "right", bg = "red").pack()

root.mainloop()
